package com.example.addressbook.controller;

import com.example.addressbook.dao.GroupRepository;
import com.example.addressbook.dao.LinkmanRepository;
import com.example.addressbook.dto.GroupingInfo;
import com.example.addressbook.dto.linkmanInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("")
public class HomeController {

    @Autowired
    LinkmanRepository linkmanRepository;

    @Autowired
    GroupRepository groupRepository;

    @GetMapping("")
    public String display(Model model){

        return "index";
    }
    //自定义SQL语句列表
    @GetMapping("allLinkman")
    public String display_linkman(Model model){
        List<linkmanInfo> linkmanInfos = linkmanRepository.linkmanInfo();
        model.addAttribute("linkmanInfos",linkmanInfos);
        List<GroupingInfo> groupingInfos = groupRepository.GroupingInfo();
        model.addAttribute("groupingInfos",groupingInfos);
        return "allLinkman";
    }


}